3d0758691f4cc39084af42c8c7c5b164b1a9bfa2,server/src/com/cloud/network/guru/DirectPodBasedNetworkGuru.java,DirectPodBasedNetworkGuru,reserve,#NicProfile#Network#VirtualMachineProfile#DeployDestination#ReservationContext#,120
Before Change
@Override
public void reserve(NicProfile nic, Network network, VirtualMachineProfile<? extends VirtualMachine> vm, DeployDestination dest, ReservationContext context)
throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException, ConcurrentOperationException {
if (nic.getIp4Address() == null) {
getIp(nic, dest.getPod(), vm, network);
nic.setStrategy(ReservationStrategy.Create);
}
DataCenter dc = _dcDao.findById(network.getDataCenterId());
After Change
}
@Override
public void reserve(NicProfile nic, Network network, VirtualMachineProfile<? extends VirtualMachine> vm, DeployDestination dest, ReservationContext context)
throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException, ConcurrentOperationException {
String oldIp = nic.getIp4Address();
boolean getNewIp = false;
if (oldIp == null) {
getNewIp = true;
} else {
// we need to get a new ip address if we try to deploy a vm in a different pod
IPAddressVO ipVO = _ipAddressDao.findByIpAndSourceNetworkId(network.getId(), oldIp);
if (ipVO != null) {
List<PodVlanMapVO> mapVO = _podVlanDao.listPodVlanMapsByVlan(ipVO.getVlanId());
if (mapVO.get(0).getPodId() != dest.getPod().getId()) {
//release the old ip here
_networkMgr.markIpAsUnavailable(ipVO.getId());
_ipAddressDao.unassignIpAddress(ipVO.getId());
nic.setIp4Address(null);
getNewIp = true;
}
}